/**
 * 实名认证
 */
define(function (require, exports, module) {


    var UI = require("js/UI"),
        uiTip=require("ui/tip");
    var $homeCnt = $("#home .cnt");

    var reg_password = /^[a-zA-Z0-9]{6,16}$/;
    var password_rule = "密码为6-12个数字或字母组合";



    var $userForm = $homeCnt.find(".userForm");

    $homeCnt.find(".bindTit a").unbind("click.name").bind("click.name", function () {
        $userForm.fadeIn();
    })

    $userForm.find("button[type=submit]").unbind("click.sub").bind("click.sub", function () {
        var $oldPW=$userForm.find(".oldPW"),$newPW=$userForm.find(".newPW"),$smtPW=$userForm.find(".smtPW");
        var _oldPW=$.trim($oldPW.val()),_newPW=$.trim($newPW.val()),_smtPW=$.trim($smtPW.val());
        var $number=$userForm.find(".number"),_number=$.trim($number.val());

        if(!_oldPW){
            var _txt=$homeCnt.hasClass("dealPW")?"初始交易密码":"请输入旧密码";
            uiTip($oldPW, _txt, "right").show();
            $oldPW.focus();
            return false
        }else if(!_oldPW.match(reg_password)){
            uiTip($oldPW, password_rule, "right").show();
            $oldPW.focus();
            return false
        }
        if(!_newPW){
            uiTip($newPW, "请输入新密码", "right").show();
            $newPW.focus();
            return false
        }else if(!_newPW.match(reg_password)){
            uiTip($newPW, password_rule, "right").show();
            $newPW.focus();
            return false
        }
        if(!_smtPW){
            uiTip($smtPW, "请输入确认密码", "right").show();
            $smtPW.focus();
            return false
        }else {
            if(!_smtPW.match(reg_password)){
                uiTip($smtPW, password_rule, "right").show();
                $smtPW.focus();
                return false
            }else{
                if(_newPW!==_smtPW){
                    uiTip($smtPW, "新密码和确认密码不一致", "right").show();
                    $smtPW.focus();
                    return false
                }
            }
        }
        if(!_number){
            uiTip($number, "请输入验证码", "right").show();
            $number.focus();
            return false
        }
    })


})